<template>
  <div class="app-container">
    <Form
      v-if="showSearch"
      v-model:formData="searchInfo"
      :formItems="formItems"
    >
      <template #footer>
        <div style="text-align: left">
          <el-button size="small" icon="Search" type="primary" @click="goSearch"
            >搜索</el-button
          >
          <el-button size="small" icon="Refresh" @click="resetSearch"
            >重置</el-button
          >
        </div>
      </template>
    </Form>
    <h3></h3>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5"> </el-col>
      <right-toolbar
        v-model:showSearch="showSearch"
        @queryTable="resetSearch"
      ></right-toolbar>
    </el-row>
    <h3>
      <!-- <el-button
        size="small"
        type="primary"
        icon="Plus"
        @click="add"
        v-hasPermi="['api:czBank:add']"
        >添加</el-button
      > -->
    </h3>
    <div style="border: 0.5px solid #dbdbdb; padding: 0 20px">
      <el-collapse v-model="activeName" accordion>
        <el-collapse-item
          :title="item.title"
          :name="item.id"
          v-for="item in info.items"
          :key="item.id"
        >
          <div style="display">
            <p>{{ item.con }}</p>
            <p></p>
          </div>
        </el-collapse-item>
      </el-collapse>
    </div>

    <pagination
      v-show="info.total > 0"
      :total="info.total"
      v-model:page="searchInfo.pageNum"
      v-model:limit="searchInfo.pageSize"
      @pagination="getInfo"
    />
    <!-- <Dialog
      width="30%"
      :title="dialogConfig.title"
      v-model:isShowDialog="isShowDialog"
      @confirm="submit"
    >
      <Form ref="formRef" v-bind="dialogConfig.formConfig"> </Form>
    </Dialog> -->
  </div>
</template>

<script>
import { formItems } from "./config";
import { getList, changeRed } from "@/api/member/message";
export default {
  name: "platformmessageindex",
  data() {
    return {
      //   dialogConfig,
      curItem: {},
      showSearch: true,
      isShowDialog: false,
      //   propList,
      formItems,
      isLoading: true,
      info: {},
      activeName: null,

      searchInfo: {
        status: "",
        name: "",
        pageNum: 1,
        pageSize: 10,
        created_at: [],
        // this.getTimeFilterDefault(true)
      },
    };
  },
  computed: {},
  created() {
    this.init();
  },
  mounted() {},
  methods: {
    init() {
      this.getInfo();
    },
    async getInfo() {
      this.isLoading = true;
      const params = { ...this.searchInfo };
      const { data } = await getList(params);
      this.info = data;
      this.isLoading = false;
    },
    resetSearch() {
      this.searchInfo = this.$options.data.call(this).searchInfo;
      //   this.searchInfo.created_at = this.getTimeFilterDefault(true);
      this.searchInfo.created_at = [];
      this.getInfo();
    },
    goSearch() {
      // 重置时间
      this.getInfo();
    },
    // submit() {
    //   this.$refs.formRef.validate(async (valid) => {
    //     if (valid) {
    //       console.log(this.dialogConfig.formConfig.formData);
    //       const params = { ...this.dialogConfig.formConfig.formData };
    //       if (params.id) {
    //         await change(params);
    //       } else {
    //         await add(params);
    //       }
    //       this.$message.success("操作成功");
    //       this.isShowDialog = false;
    //       this.getInfo();
    //     }
    //   });
    // },
    // add() {
    //   this.dialogConfig.formConfig.formData = {};
    //   this.isShowDialog = true;
    // },
    change(item) {
      // 修改
      //   this.dialogConfig.formConfig.formData = { ...item };
      //   this.isShowDialog = true;
    },
    del(item) {
      // 删除
      this.$confirm("确定要删除吗?", "提示", {
        cancelButtonText: "取消",
        confirmButtonText: "确定",
        type: "warning",
      })
        .then(async () => {
          await del(item.id);
          this.message({
            type: "success",
            message: "删除成功!",
          });
          this.getList();
        })
        .catch(() => {});
    },
  },
};
</script>

<style lang="scss" scoped></style>
